const { no, ok } = require('../../utils/utlis');
const labelService = require('../../services/admin/labelService');

module.exports = {
	list: async (req, res, next) => {
		try {
			let { keywords } = req.body;

			let relsut = await labelService.list(keywords || '');
			res.send(ok(relsut));
		} catch (error) {
			res.send(no(error.message));
		}
	},
	add: async (req, res, next) => {
		try {
			let { name, remark } = req.body;

			await labelService.add(name, remark);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	},
	edit: async (req, res, next) => {
		try {
			let { name, remark, id } = req.body;
			await labelService.edit(name, remark, id);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	},
	del: async (req, res, next) => {
		try {
			let { id } = req.body;
			await labelService.del(id);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	},
	detail: async (req, res, next) => {
		try {
			let { id } = req.body;
			let obj = await labelService.detail(id);
			res.send(ok(obj));
		} catch (error) {
			res.send(no(error.message));
		}
	}
};
